package com.yystar.support.clock.dao.impl;

import java.util.Date;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import com.yystar.support.clock.dao.ClockDao;
import com.yystar.support.clock.domain.Clock;

@Repository
public class ClockDaoImpl extends SqlSessionDaoSupport implements ClockDao {
	@Cacheable("clock")
	public Clock getCurrentClock() {
		Clock clock = new Clock();
		clock.setServerDateTime(new Date());
		clock.setDatabaseDateTime((Date) getSqlSession().selectOne("com.yystar.support.clock.dao.ClockDao.getCurrentDatabaseDateTime"));
		return clock;
	}
}
